﻿#region Using

using System;
using System.Diagnostics;
using System.Linq.Expressions;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace Common.Base
{
    [DebuggerDisplay("{X}, {Y} / {Width}x{Height}")]
    public class Dimension : ICloneable
    {
        public Dimension()
        {
            this.Size = new Size();
            this.Position = new Position();
        }

        public Dimension(Position position)
        {
            this.Position = position;
            this.Size = new Size();
        }

        public Dimension(Dimension dimension)
        {
            this.Position = new Position(dimension.X, dimension.Y);
            this.Size = new Size(dimension.Width, dimension.Height);
        }

        public Dimension(Size size)
        {
            this.Position = new Position();
            this.Size = size;
        }

        public Dimension(Position position, Size size)
        {
            this.Position = position;
            this.Size = size;
        }

        public Dimension(Position position, int width, int height)
        {
            this.Position = position;
            this.Size = new Size(width, height);
        }

        public Dimension(int x, int y)
        {
            this.Position = new Position(x, y);
            this.Size = new Size();
        }

        public Dimension(int x, int y, int width, int height)
        {
            this.Position = new Position(x, y);
            this.Size = new Size(width, height);
        }

        public Dimension(int x, int y, Texture2D texture)
        {
            this.Position = new Position(x, y);
            this.Size = new Size(texture.Width, texture.Height);
        }

        public Dimension(Position pos, Texture2D texture)
        {
            this.Position = pos;
            this.Size = new Size(texture.Width, texture.Height);
        }

        public Dimension(int x, int y, Size size)
        {
            this.Position = new Position(x, y);
            this.Size = size;
        }

        public int Height
        {
            get
            {
                return this.Size.Height;
            }

            set
            {
                this.Size.Height = value;
            }
        }

        public Position Position { get; set; }

        public Rectangle Rectangle
        {
            get
            {
                return new Rectangle(this.X, this.Y, this.Width, this.Height);
            }
        }

        public Size Size { get; set; }

        public int Width
        {
            get
            {
                return this.Size.Width;
            }

            set
            {
                this.Size.Width = value;
            }
        }

        public int X
        {
            get
            {
                return this.Position.X;
            }

            set
            {
                this.Position.X = value;
            }
        }

        public int Y
        {
            get
            {
                return this.Position.Y;
            }

            set
            {
                this.Position.Y = value;
            }
        }

        public object Clone()
        {
            return new Dimension(this.X, this.Y, this.Width, this.Height);
        }
    }
}